package com.btr.ivle.helper;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.btr.ivle.R;

public class ModuleItemListAdapter extends ArrayAdapter<Map<String,String>> {
	
    public ModuleItemListAdapter(Context context, List<Map<String, String>> list) {
        super(context, 0, list);
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    	View view = convertView;
    	view = LayoutInflater.from(getContext()).inflate(R.layout.list_item_moduleitem, null);
    	
    	TextView tvTitle = (TextView) view.findViewById(R.id.ItemTitle);
    	tvTitle.setText(getItem(position).get("item"));
    	
    	TextView tvDescription = (TextView) view.findViewById(R.id.ItemDescription);
    	if(getItem(position).containsKey("name")){
	    	tvDescription.setText(getItem(position).get("name"));
    	}else{
    		tvDescription.setVisibility(View.GONE);
    	}
    	
    	TextView tvUnread = (TextView) view.findViewById(R.id.unreadcount);
    	if(getItem(position).containsKey("unread")){
	    	tvUnread.setText(getItem(position).get("unread"));
    	}else{
    		tvUnread.setVisibility(View.INVISIBLE);
    	}
        return view;
    }
}
